<?php

namespace App\Http\Admin\Controllers;
use App\Services\system\SystemAdminServices;
use App\Http\Controllers\Controller;
use App\Requests\UserRequest;
use Hlcreation\Basic\Helper;
use Illuminate\Http\Request;

/**
 *   登录操作
 * */

class LoginController  extends Controller
{

    /**
     * @param SystemAdminServices $services
     */
    public function __construct(SystemAdminServices $services)
    {
        $this->services = $services;
    }


    //登录处理
    public function login(UserRequest  $request)
    {
        $all = $request->all();
        $data=$this->services->login($all['account'],$all['password']);
        return  Helper::toJson('登录成功',200,$data);
    }



    public function updatePwd(Request $request){


        $all = $request->all();

        $userInfo = Helper::getPost('userinfo');

        $uid = $userInfo['user_info']['id'];  //创建者


        $data = $this->services->save($uid,$all);

        if($data){
            return Helper::toJson("修改密码成功", 200);
        }else{
            return Helper::toJson("修改密码失败", 400);
        }

    }



}
